﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Graphics;

namespace Fusion.Interface
{
    public class TextList : Entity
    {
        public List<string> entries = new List<string>();
        public int itemsToDraw;
        public int startIndex;

        public SpriteFont font;

		public float listSeparation;

        public TextList()
        {
            font = Engine.Fonts.Get( "default" );
        }

        public void SetLayerNames( List<Entity> entities )
        {
            entries.Clear();
            int i = 0;
            foreach( Entity entity in entities )
            {
                string entName = entity.name;
                if( entName == "" )
                    entName = "Entity";

                entries.Add( "Layer " + i.ToString() + ": " + entName );
                i++;
            }

        }

        public override void Draw()
        {
            Engine.spriteBatch.DrawString( font, name, position, Color.White, 0, Vector2.Zero, scale, SpriteEffects.None, 0.5f );
            for( int i = 0; i < itemsToDraw; i++ )
            {
                int index = i + startIndex;
                if( index >= entries.Count || index < 0 )
                    return;

				Engine.spriteBatch.DrawString( font, entries[index], position + new Vector2( 16, 24 + ( 24 * i ) ), Color.White, 0, Vector2.Zero, scale, SpriteEffects.None, 0.5f );
            }
        } // Renders a text list of the entity heirachy
    }
}
